package cn.flyinke.jc;

import java.util.Arrays;
import java.util.List;

import org.casbin.jcasbin.model.Model;
import org.casbin.jcasbin.persist.Adapter;

import com.jfinal.kit.JsonKit;

public class JCasbinAdapter implements Adapter{

	@Override
	public void loadPolicy(Model model) {
	
		System.out.println(JsonKit.toJson(model.model));
		
		
		List<String> pList0 = Arrays.asList(new String[] {"alice","/dataset1/*","GET"});
		model.model.get("p").get("p").policy.add(pList0);
		
		List<String> pList1 = Arrays.asList(new String[] {"alice","/dataset1/resource1","POST"});
		model.model.get("p").get("p").policy.add(pList1);
		
		List<String> pList2 = Arrays.asList(new String[] {"bob","/dataset2/resource1","*"});
		model.model.get("p").get("p").policy.add(pList2);
		
		List<String> pList3 = Arrays.asList(new String[] {"bob","/dataset2/resource2","GET"});
		model.model.get("p").get("p").policy.add(pList3);
		
		List<String> pList4 = Arrays.asList(new String[] {"bob","/dataset2/folder1/*","POST"});
		model.model.get("p").get("p").policy.add(pList4);
		
		List<String> pList5 = Arrays.asList(new String[] {"dataset1_admin","/dataset1/*","*"});
		model.model.get("p").get("p").policy.add(pList5);
		
		List<String> gList0 = Arrays.asList(new String[] {"cathy","dataset1_admin"});
		model.model.get("g").get("g").policy.add(gList0);
		
		
	}

	@Override
	public void savePolicy(Model model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void addPolicy(String sec, String ptype, List<String> rule) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removePolicy(String sec, String ptype, List<String> rule) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removeFilteredPolicy(String sec, String ptype, int fieldIndex, String... fieldValues) {
		// TODO Auto-generated method stub
		
	}

}
